<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 引入vue2的js文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.9/vue.js"></script>
  </head>
  <body>
    <!-- MVVM中的View视图 -->
    <div id="app">
      <!-- 下面这种写法，src的值就写死了 -->
      <!-- <img
        src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F4423599a-df06-44c6-9493-f2f831c3b990%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1697610285&t=a247d38189f45acf67ba301c512f8e22"
        alt=""
      /> -->
      <!-- 下面这种写法，src的值就没有写死 -->
      <!-- <img style="width: 600px" v-bind:src="imgUrl" alt="" /> -->
      <!-- v-bind:可以简写成: -->
      <img style="width: 600px" :src="imgUrl" alt="" />
      <!-- <button v-on:click="change">换一个</button> -->
      <!-- 如果你非得手动传递时间对象，那么你可以通过标识符 $event进行传递 -->
      <button @click="change($event)">换一个</button>
      <!-- v-on: 可以简化成 @ -->
      <hr />
      <p>{{ msg }}</p>
      <button @click="changeMsg('我也是一个好人',112233)">点击传值</button
      ><br />
      <input type="text" @input="inputChange" />
    </div>

    <script>
      // MVVM中的ViewModel
      new Vue({
        el: '#app',
        data: {
          msg: '你是一个好人',
          imgUrl:
            'https://img1.baidu.com/it/u=2929710579,3996007340&fm=253&fmt=auto&app=120&f=JPEG?w=1422&h=800'
        },
        methods: {
          change(e) {
            console.log('---change---', e)
            this.imgUrl =
              'https://img2.baidu.com/it/u=1080054040,2083216744&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'
          },
          changeMsg(msg, other) {
            console.log(msg, other)
            this.msg = msg
          },
          inputChange(e) {
            console.log(e)
          }
        }
      })
    </script>
  </body>
</html>
